#include "login.h"
#include "ui_login.h"
#include <QBitmap>
#include <QPainter>
#include <QPalette>
#include <QBrush>
#include <QApplication>
#include <QMessageBox>

Login::Login(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Login)
{
    ui->setupUi(this);
    setWindowFlags(Qt::FramelessWindowHint);
    //设置关于窗体为圆角
    QBitmap bmp(this->size());
    bmp.fill();
    QPainter p(&bmp);
    p.setPen(Qt::NoPen);
    p.setBrush(Qt::black);
    p.drawRoundedRect(bmp.rect(),20,20);
    setMask(bmp);
    //设置textBrowser为背景颜色
    QPalette palette = ui->ABC->palette();
    palette.setBrush(QPalette::Base, QBrush(Qt::NoBrush));
    ui->ABC->setPalette(palette);
    ui->usrname->setFocus();

}

Login::~Login()
{
    delete ui;
}

void Login::on_pushButton_2_clicked()
{
    QApplication::exit();
}

void Login::on_pushButton_clicked()
{
    if ((ui->usrname->text() == "admin") && (ui->password->text() == "123456"))
        accept();
    else
    {
        QMessageBox::warning(this,tr("警告"),tr("用户名或密码错误!"),QMessageBox::Yes);
        ui->usrname->clear();
        ui->password->clear();
        ui->usrname->setFocus();
    }
}
